package jp.eisbahn.mgapi.api;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

public abstract class Model {
    
    private JSONObject original;
    
    protected Model(JSONObject original) {
        super();
        this.original = original;
    }
    
    protected String getPropertyString(String propertyName) {
        return (String)original.get(propertyName);
    }
    
    protected int getPropertyInt(String propertyName) {
        return (Integer)original.get(propertyName);
    }
    
    @SuppressWarnings("unchecked")
    protected String[] getPropertyStringArray(String propertyName) {
        JSONArray array = (JSONArray)original.get(propertyName);
        return (String[])array.toArray(new String[0]);
    }

}
